﻿<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="ProductList_ListView.ascx.cs"
    Inherits="TelerikStore.Views.ProductList_ListView" %>
<telerik:RadCodeBlock ID="RadCodeBlock1" runat="server">
    <script type="text/javascript">
        function listViewItemDropping(sender, args) {
            var dropTarget = args.get_destinationElement();
            var isCorrectTarget = $(dropTarget).is("#cart-overview *");
            if (!isCorrectTarget) args.set_cancel(true);
        }

        function showLoadingPanel() {
            var loadingPanel = $find('<%= (this.NamingContainer.FindControl("LoadingPanel") as RadAjaxLoadingPanel).ClientID %>');
            loadingPanel.show('<%= this.Parent.ClientID %>');
        }
    </script>
</telerik:RadCodeBlock>
<telerik:RadListView ID="ProductListView" runat="server" AllowPaging="true" OnNeedDataSource="ProductListView_NeedDataSource"
    OnItemDrop="ProductListView_ItemDrop" DataKeyNames="Id" OnItemCommand="ProductListView_ItemCommand">
    <ClientSettings AllowItemsDragDrop="true">
        <ClientEvents OnItemDropping="listViewItemDropping" />
    </ClientSettings>
    <LayoutTemplate>
        <ul>
            <div id="itemPlaceholder" runat="server">
            </div>
        </ul>
        <div class="paging numeric-paging">
            <telerik:RadDataPager ID="BottomPager" runat="server" PageSize="8" EnableEmbeddedSkins="false"
                EnableEmbeddedBaseStylesheet="false">
                <Fields>
                    <telerik:RadDataPagerButtonField FieldType="Numeric" />
                </Fields>
            </telerik:RadDataPager>
        </div>
    </LayoutTemplate>
    <ItemTemplate>
        <li class="rlvI">
            <div class="rlvDrag" onmousedown="Telerik.Web.UI.RadListView.HandleDrag(event, '<%# Container.OwnerListView.ClientID %>', <%# Container.DisplayIndex %>)">
                <a href="#" class="thumb">
                    <asp:ImageButton ID="ProductDetailsButton" runat="server" ImageUrl='<%# Eval("SmallPicture") %>'
                        OnClientClick="showLoadingPanel()" AlternateText='<%# Eval("Title") %>' CommandName="ProductClick"
                        CommandArgument='<%# Container.DisplayIndex %>' />
                </a>
                <h3 class="title">
                    <asp:Literal ID="TitleLiteral" runat="server" Text='<%# Eval("Title") %>' />
                </h3>
                <p class="price-and-buy">
                    <asp:Literal runat="server" Text='<%# ColorizePrice(Container) %>' />
                    <span class="buy">
                        <telerik:RadButton ID="BuyButton" runat="server" Text="Add to Cart" EnableEmbeddedSkins="false"
                            AutoPostBack="true" CommandName="AddToCart" CommandArgument='<%# Eval("Id") %>' />
                    </span>
                </p>
            </div>
        </li>
    </ItemTemplate>
</telerik:RadListView>

